
<template>
  <h2>封装的axios</h2>
  <el-button @click="getData">发送</el-button>
  <h2>未封装的axios</h2>
  <el-button @click="getData1">发送</el-button>
  <h2>node服务</h2>
  <el-button @click="getData2">发送</el-button>
  <el-button @click="getData3">路径参数</el-button>
  <el-button @click="getData4">POST请求</el-button>
  <el-button @click="getData5">微信登录</el-button>
</template>
<script setup lang="ts">
import instance, { nodeService, loginService } from '@/service/index'
import type { AxiosResponse } from 'axios'
import axios from 'axios'
interface Res {
  message: string;
  code: number;
  list: string[];
}

const getData = () => {
  instance.get('/m1/2874770-0-default/province').then((res:any) => {
    console.log(res.list)
  })
}

const getData1 = () => {
  axios.get('https://apifoxmock.com/m1/2874770-0-default/province').then((res:AxiosResponse<Res>) => {
    console.log(res.data.list)
  })
}

const getData2 = () => {
  const params = {
    id: 123,
    languages: ['chinese', 'english']
  }
  nodeService.get('/', { params }).then((res:any) => {
    console.log(res)
  })
}
const getData3 = () => {
  nodeService.get('/student/2345').then((res:any) => {
    console.log(res)
  })
}
const getData4 = () => {
  const params = {
    name: '中国',
    address: 'ashia'
  }
  nodeService.post('/rank', params).then((res:any) => {
    console.log(res)
  })
}
const getData5 = () => {
  loginService.get('/0c3b5N0001YuXR152l2008JVHY1b5N0I').then((res:any) => {
    console.log(res)
  })
}

</script>
